package com.tiankong.ware.controller;


import com.tiankong.ware.entity.WareInfo;
import com.tiankong.ware.service.WareInfoService;
import net.youdi.common.filter.PageFilter;
import net.youdi.common.model.Page;
import net.youdi.common.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

/**
 * <p>
 * 仓库信息 前端控制器
 * </p>
 *
 * @author scl
 * @since 2021-03-22
 */
@RestController
@RequestMapping("/wareinfo")
public class WareInfoController {

    @Autowired
    private WareInfoService wareInfoService;

    @GetMapping("list/page")
    public Result pageList(PageFilter filter){
        Page page = wareInfoService.queryPage(filter);
        return Result.ok().setPage(page);
    }
    @PostMapping("save")
    public Result save(@RequestBody WareInfo wareInfo){
        wareInfoService.save(wareInfo);
        return Result.ok(wareInfo);
    }
    @PostMapping("update")
    public Result update(@RequestBody WareInfo wareInfo){
        wareInfoService.updateById(wareInfo);
        return Result.ok(wareInfo);
    }
    @GetMapping("info/{id}")
    public Result info(@PathVariable("id") Long id){
        WareInfo wareInfo = wareInfoService.getById(id);
        return Result.ok(wareInfo);
    }
    @DeleteMapping("delete")
    public Result info(@RequestBody Set<Long> ids){
        wareInfoService.removeByIds(ids);
        return Result.ok();
    }
}
